package com.pratik.android.smssniffer.services;

import com.pratik.android.smssniffer.handlers.CommandHandlerService;
import com.pratik.android.smssniffer.handlers.MessageHandlerService;
import com.pratik.android.smssniffer.handlers.impl.HandlersServiceRegistry;
import com.pratik.android.smssniffer.telelphony.MessageGeneratorService;
import com.pratik.android.smssniffer.telelphony.SmsService;
import com.pratik.android.smssniffer.telelphony.impl.TelephonyServiceRegistry;

import android.content.Context;

public class GlobalServiceRegistry {

	public static GlobalServiceRegistry instance;

	public static GlobalServiceRegistry getInstance() {
		if (instance == null)
			return instance = new GlobalServiceRegistry();
		return instance;
	}

	private boolean init = false;

	public void init(Context context) {
		if (init)
			return;

		HandlersServiceRegistry.getInstance().init();
		TelephonyServiceRegistry.getInstance().init();

		init = true;
	}

	public MessageHandlerService getMessageHandlerService() {
		return HandlersServiceRegistry.getInstance().getMessageHandlerService();
	}

	public CommandHandlerService getCommandHandlerService() {
		return HandlersServiceRegistry.getInstance().getCommandHandlerService();
	}

	public SmsService getSmsService() {
		return TelephonyServiceRegistry.getInstance().getSmsService();
	}

	public MessageGeneratorService getMessageGeneratorService() {
		return TelephonyServiceRegistry.getInstance()
				.getMessageGeneratorService();
	}

}
